package com.bugstack.domain.activity.service.quota.policy.impl;

import com.bugstack.domain.activity.model.aggregate.CreateOrderAggregate;
import com.bugstack.domain.activity.model.valobj.OrderStateVO;
import com.bugstack.domain.activity.reopsitory.IActivityRepository;
import com.bugstack.domain.activity.service.quota.policy.ITradePolicy;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @Author: czb
 * @Description: TODO
 * @DateTime: 2025/4/16 15:48
 **/
@Slf4j
@Component("credit_pay_trade")
public class CreditPayTradePolicy implements ITradePolicy {

    private final IActivityRepository repository;

    public CreditPayTradePolicy(IActivityRepository repository) {
        this.repository = repository;
    }

    @Override
    public void trade(CreateOrderAggregate createOrderAggregate) {
        log.info("使用积分支付策略 orderId:{}", createOrderAggregate.getActivityOrderEntity().getOrderId());
        createOrderAggregate.setState(OrderStateVO.wait_pay);
        repository.doSaveCreditPayOrder(createOrderAggregate);
    }
}
